

package cn.shengchao.base.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public class PaySuccessMessageEvent extends BaseEvent<PaySuccessMessageEvent.PaySuccessMessage> {

    public PaySuccessMessageEvent(Object source) {
        super(source);
        this.buildEventMessage((PaySuccessMessage)source);
    }

    @Override
    public EventMessage<PaySuccessMessage> buildEventMessage(PaySuccessMessage data) {
        return EventMessage.<PaySuccessMessage>builder()
            .id(RandomStringUtils.randomNumeric(11))
            .timestamp(new Date())
            .data(data)
            .build();
    }

    @Override
    public String topic() {
        return "pay_success";
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class PaySuccessMessage {
        private String userId;
        private String tradeNo;
        private String productId;
        private String shareCode;
        private BigDecimal amount;
        private List<String> subProductIds;
        private String productType;
        private String payType;
        private Date payTime;
    }

}
